package it.unicam.cs.cosy.bioshape.core.components;

import java.io.Serializable;

/**
 * Generic class representing a pair.
 * 
 * // TODO Luca a che serve? O_O
 * 
 * @author Federico Buti
 * 
 * @param <T1>
 *            the type of <i>first</i> element contained in the pair
 * @param <T2>
 *            the type of <i>second</i> element contained in the pair
 */
public class Pair<T1, T2> implements Serializable {

    @Override
    public int hashCode() {
        final int prime = 92821;
        int result = 1;
        result = prime * result + ((e1 == null) ? 0 : e1.hashCode());
        result = prime * result + ((e2 == null) ? 0 : e2.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Pair<?, ?> other = (Pair<?, ?>) obj;
        if (e1 == null) {
            if (other.e1 != null)
                return false;
        } else if (!e1.equals(other.e1))
            return false;
        if (e2 == null) {
            if (other.e2 != null)
                return false;
        } else if (!e2.equals(other.e2))
            return false;
        return true;
    }

    /**
	 * 
	 */
    private static final long serialVersionUID = -337649543705692390L;

    protected T1 e1;

    protected T2 e2;

    /**
     * Builds a pair
     * 
     * @param e1
     *            The first element of the pair to be set
     * @param e2
     *            The second element of the pair to be set
     */
    public Pair(T1 e1, T2 e2) {
        this.e1 = e1;
        this.e2 = e2;
    }

    /**
     * Getter.
     * 
     * @return The first element of the pair
     */
    public T1 getE1() {
        return e1;
    }

    /**
     * Setter.
     * 
     * @param e1
     *            The first element of the pair to be set
     */
    public void setE1(T1 e1) {
        this.e1 = e1;
    }

    /**
     * Getter.
     * 
     * @return The second element of the pair
     */
    public T2 getE2() {
        return e2;
    }

    /**
     * Setter.
     * 
     * @param e2
     *            The second element of the pair to be set
     */
    public void setE2(T2 e2) {
        this.e2 = e2;
    }


}
